define(function(require, exports, module) {
	var _touch = require('bigfoot/dhtml/touch'), 
	_scrollTab = require('bigfoot/widget/tab/scrollTab');

	exports.init = function(scrollTab){
		var touch = Object.create(_touch);
		touch.el = scrollTab.mover.parentNode;

	//	touch.onMoving = function(e, direction, x1,lastX){
	//        var el = this.el;          // 正在移动着的元素
	//        var el_Left = getTransform3D_Left(el);
	//        var isReturnFalse;
	//		if(direction == 'left' || direction == 'right'){
	//	        var leftValue = el_Left + (x1 - lastX);
	//    	    el.style.webkitTransition = '-webkit-transform 0ms linear';
	//    		el.style.webkitTransform  = 'translateX(-{0}%)'.format(leftValue);
	//            
	//		}
	//		console.log(el_Left)
	//		e && e.preventDefault();
	//	}
	//	
		
		if(!scrollTab.goNext){// 为保存 scrollTab 耦合度不要太强，所以就算是 go/goNext 这些方法都分离出去
			for(var i in _scrollTab.loopController){
				scrollTab[i] = _scrollTab.loopController[i];
			}
		}

		touch.onAfterMove = goSide.bind(scrollTab);
		touch.init();
	}

	//
	function goSide(e, data){
		// data.disX 
	    if (data.direction == 'right') {
	        // right2left
	        this.goNext();
	    } else if (data.direction == 'left') {
	        // left2right
	    	this.goPrevious();
	    }
	}

	/**
	 * @param {HTMLElement}
	 * @returns {Number}
	 */
	function getTransform3D_Left(el){
		var value = el.style.webkitTransform;
		if(!value)value = 0;
		try{
			value = value.split('(').pop().split('%').shift();
			value = Number(value);
		}catch(e){
			value = 0;
		}
		return value;
	}
});